package interfaz;

import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import java.awt.Dimension;

public class InterfazTecnico implements IVista{

	private JFrame frame;
	private JPanel pnlFuncionalidad;
	private JButton btnMisIncidencias;
	private JButton btnModificarDatos;

	/**
	 * Create the application.
	 */
	public InterfazTecnico() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setMinimumSize(new Dimension(800, 680));
		frame.setBounds(100, 100, 643, 394);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{238, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		frame.getContentPane().setLayout(gridBagLayout);
		
		JPanel panel = new JPanel();
		panel.setBorder(new LineBorder(new Color(0, 0, 0)));
		panel.setBackground(Color.WHITE);
		GridBagConstraints gbc_panel = new GridBagConstraints();
		gbc_panel.insets = new Insets(0, 0, 0, 5);
		gbc_panel.fill = GridBagConstraints.BOTH;
		gbc_panel.gridx = 0;
		gbc_panel.gridy = 0;
		frame.getContentPane().add(panel, gbc_panel);
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[]{30, 0, 0};
		gbl_panel.rowHeights = new int[]{30, 0, 0, 15, 0, 0};
		gbl_panel.columnWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
		gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		panel.setLayout(gbl_panel);
		
		btnModificarDatos = new JButton("Modificar datos de cuenta");
		btnModificarDatos.setActionCommand("modificarDatos");
		GridBagConstraints gbc_btnModificarDatos = new GridBagConstraints();
		gbc_btnModificarDatos.insets = new Insets(0, 0, 5, 0);
		gbc_btnModificarDatos.gridx = 1;
		gbc_btnModificarDatos.gridy = 2;
		panel.add(btnModificarDatos, gbc_btnModificarDatos);
		
		btnMisIncidencias = new JButton("Mis incidencias");
		GridBagConstraints gbc_btnMisIncidencias = new GridBagConstraints();
		gbc_btnMisIncidencias.fill = GridBagConstraints.HORIZONTAL;
		gbc_btnMisIncidencias.gridx = 1;
		gbc_btnMisIncidencias.gridy = 4;
		panel.add(btnMisIncidencias, gbc_btnMisIncidencias);
		
		pnlFuncionalidad = new JPanel();
		pnlFuncionalidad.setBackground(Color.WHITE);
		GridBagConstraints gbc_pnlFuncionalidad = new GridBagConstraints();
		gbc_pnlFuncionalidad.fill = GridBagConstraints.BOTH;
		gbc_pnlFuncionalidad.gridx = 1;
		gbc_pnlFuncionalidad.gridy = 0;
		frame.getContentPane().add(pnlFuncionalidad, gbc_pnlFuncionalidad);
	}

	@Override
	public void update() {
		this.frame.revalidate();
		this.frame.repaint();
		
	}

	@Override
	public void SetVisible(boolean visible) {
		frame.setVisible(visible);
		
	}

	@Override
	public void registerListener(ActionListener listener) {
		this.btnMisIncidencias.addActionListener(listener);
		this.btnModificarDatos.addActionListener(listener);
	}
	
	public void setPanelFuncionalidad(JPanel panelFuncionalidad) {
		frame.getContentPane().remove(this.pnlFuncionalidad);
		
		panelFuncionalidad.setBorder(new LineBorder(new Color(0, 0, 0)));
		GridBagConstraints gbc_panelFuncionalidad = new GridBagConstraints();
		gbc_panelFuncionalidad.fill = GridBagConstraints.BOTH;
		gbc_panelFuncionalidad.gridx = 1;
		gbc_panelFuncionalidad.gridy = 0;
		frame.getContentPane().add(panelFuncionalidad, gbc_panelFuncionalidad);
		this.pnlFuncionalidad= panelFuncionalidad;
	}

}
